import java.util.Random;
import java.io.IOException;
import javax.microedition.lcdui.*;
import pica.ui.*;

public final class a extends b
{

    public a(h h1, String s1, int i1, int j1)
    {
        super(h1, s1);
        new Random();
        s = 0xffffff;
        u = Font.getFont(0, 0, 8);
        super.g = i1;
        super.h = j1;
        o = k[n];
        q = 10;
        r = -70;
    }

    public static void a()
    {
         try {i = new Image[4];

		    i[0] = Image.createImage("/middle/bg.png");

	    i[1] = i[0];
        i[2] = i[0];
        i[3] = i[0];
        k = (new Image[] {
            Image.createImage("/middle/contact.png"), Image.createImage("/middle/chatroom.png"), Image.createImage("/middle/picabar.png"), Image.createImage("/middle/picazone.png")
        });
        j = Image.createImage("/middle/button.png");
         } catch (IOException e) {
		    e.printStackTrace(); 
	    }
        return;
    }

    public final String b()
    {
        return m[n];
    }

    protected final void a(Graphics g)
    {
        g.setFont(u);
        if(q < 10 || r > -70)
            if(h.g)
            {
                q += 20;
                r -= 20;
            } else
            {
                q = 10;
                r = -70;
            }
        g.setClip(super.e, super.f, super.g, super.h);
        g.setColor(24220);
        g.fillRect(super.e, super.f, super.g, super.h);
        for(int i1 = 0; i1 < i.length; i1++)
            g.drawImage(i[i1], l[i1], super.h, 36);

        int ai[] = {
            super.g - (j.getWidth() / 2 + 20), super.g - (j.getWidth() / 2 + 5), super.g - (j.getWidth() / 2 + 5), super.g - (j.getWidth() / 2 + 20)
        };
        int ai1[] = {
            (super.h - 19) / 2 - 45, (super.h - 19) / 2 - 15, (super.h - 19) / 2 + 15, (super.h - 19) / 2 + 45
        };
        if(o != null)
            g.drawImage(o, q, (super.h - 19) / 2, 6);
        if(p != null)
            g.drawImage(p, r, (super.h - 19) / 2, 6);
        for(int j1 = 0; j1 < ai.length; j1++)
            if(j1 == n)
            {
                g.drawImage(j, ai[j1], ai1[j1], 3);
                f.a(m[j1], ai[j1] - 1, ai1[j1] - u.getHeight() / 2, 0xac2a0a, -1, 17, g);
            } else
            {
                f.a(m[j1], ai[j1], (ai1[j1] - u.getHeight() / 2) + 1, -1, 0, 17, g);
            }

        if(t)
        {
            if((s | 0xffffff) != -1)
                s = s + 0xf000000;
            a(g, super.g, super.h, s);
        }
    }

    public final void a(boolean flag)
    {
        t = flag;
    }

    protected final boolean a(byte byte0, int i1)
    {
        boolean flag = false;
        if(byte0 == 0)
            switch(super.b.getGameAction(i1))
            {
            case 2: // '\002'
            case 3: // '\003'
            case 4: // '\004'
            case 5: // '\005'
            case 7: // '\007'
            default:
                break;

            case 8: // '\b'
                if(super.a != null)
                    super.a.a(7, m[n]);
                flag = true;
                break;

            case 1: // '\001'
                flag = true;
                n--;
                if(n < 0)
                    n = 3;
                p = o;
                r = q;
                o = k[n];
                q = -70;
                break;

            case 6: // '\006'
                flag = true;
                n++;
                if(n > 3)
                    n = 0;
                p = o;
                r = q;
                o = k[n];
                q = -70;
                break;
            }
        return flag;
    }

    private static void a(Graphics g, int i1, int j1, int k1)
    {
        int ai[] = new int[i1 * j1];
        for(int l1 = 0; l1 < ai.length; l1++)
            ai[l1] = k1;

        Image image = Image.createRGBImage(ai, i1, j1, true);
        g.drawImage(image, 0, 0, 20);
    }

    protected final boolean a(byte byte0, int i1, int j1)
    {
        if(byte0 == 0)
            return a(i1, j1);
        else
            return false;
    }

    private boolean a(int i1, int j1)
    {
        boolean flag = false;
        int ai[] = {
            super.g - 60, super.g - 45, super.g - 45, super.g - 60
        };
        int ai1[] = {
            (super.h - 19) / 2 - 45, (super.h - 19) / 2 - 15, (super.h - 19) / 2 + 15, (super.h - 19) / 2 + 45
        };
        int k1 = 0;
        do
        {
            if(k1 >= ai.length)
                break;
            if(f.a(i1, j1, ai[k1] - j.getWidth() / 2, ai1[k1] - j.getHeight() / 2, j.getWidth(), j.getHeight()))
            {
                n = k1;
                c();
                if(super.a != null)
                    super.a.a(7, m[n]);
                flag = true;
                break;
            }
            k1++;
        } while(true);
        return flag;
    }

    private void c()
    {
        super.b.repaint();
        super.b.serviceRepaints();
    }

    private static Image i[];
    private static Image j;
    private static Image k[];
    private int l[] = {
        0, 76, 152, 228
    };
    private String m[] = {
        "\u6211\u7684\u597D\u53CB", "\u7FA4&\u804A\u5929\u5BA4", "PICA\u5427", "PICA\u4E50\u56ED"
    };
    private int n;
    private Image o;
    private Image p;
    private int q;
    private int r;
    private int s;
    private boolean t;
    private Font u;
}
